/*
 * TinyWiki ieDontSupportTarget - v0.1.0
 *  Copyright 2010 - 2011, itozyun
 *  Released under the MIT, BSD, and GPL Licenses.
 */

// Target擬似クラスに対応しないIE6-8用。閲覧時のみ。
	(function(){
		if( !!document.uniqueID){
			var wiki = wiki || {};
			wiki.ieDontSupportTarget = (function(){
				var	navi = document.getElementById( 'sitemap').getElementsByTagName( 'a'),
					pages = document.getElementById( 'content').childNodes,
					l = pages.length;	
				return {
					init: function(){
						for( var i=0; i<l; ++i){
							var link = navi[ i];
							link.onclick = new Function( 'wiki.ieDontSupportTarget.focus( this)');
						}
						delete wiki.ieDontSupportTarget.init;		
					},
					focus: function( a){
						var id = a.href.replace( /.*#(.*)/, '$1');
						for( var i=0; i<l; i++){
							var page = pages[ i];
							if( page.className && page.className === 'tinywiki-page'){
								page.style.display = ( page.id === id) ? 'block' : '';
							}
						}
						return false;
					},
					remove: function(){
						for( var i=0; i<l; ++i){
							navi[ i].onclick = undefined;
						}
						delete wiki.ieDontSupportTarget;
					}					
				}
			})();
			wiki.ieDontSupportTarget.init();
		}
	})();
